var express = require("express");
var router = express.Router();
const fs = require("fs");
const path = require("path");
/* GET home page. */
router.get("/", function (req, res, next) {
  console.log('88888--------123123')
  //render作用 绘制(渲染)视图
  res.render("index", {
    title: "快,好快",
    age: "30",
    el: "<del>998</del>",
    arr: ["吃法", "写代码", "改bug"],
  });
});

//添加一个路由 匹配video路径

router.get("/video", (req, res) => {
  //读取assets video下面的文件,并且展示
  // console.log(path.resolve("assets/video"));
  let readRes = fs.readdirSync(path.resolve("assets/video"));
  // res.send("8888");
  //过滤掉 .DS_Store这个文件
  readRes = readRes.filter((item, index) => {
    return index !== 0;
  });
  console.log(readRes);
  //调用视图引擎
  res.render("video", { assetsPath: "/video/", data: readRes });
});

module.exports = router;
